<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2017/9/11
  Time: 17:25
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@include file="../common/include.jsp" %>
<html>
<head>
    <title>Title</title>
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content  animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox ">
                <div class="ibox-content">

                    <div class="jqGrid_wrapper">
                        <div class="ui-jqgrid " id="gbox_table_list_2" dir="ltr">
                            <div class="ui-jqgrid-view table-responsive" role="grid" id="gview_table_list_2"
                            >


                                <form role="form" class="form-inline" style="margin-bottom: 10px" id="searchForm"
                                      method="post" action="getRejectSourceList.html">
                                    <input type="hidden" id="status" name="status" value="${status}">
                                    <input type="hidden" id="status1" name="status1" value="${status1}">
                                    <input type="hidden" id="pageName" name="pageName" value="${pageName}">
                                    <div class="form-group">


                                        <input type="text" name="conditions['createName']" placeholder="录入人"
                                               value="${pages.conditions.createName}"
                                               id="createName" class="form-control">&nbsp;&nbsp;&nbsp;
                                        <select id="demandProduct" name="conditions['demandProduct']"
                                                class="form-control"
                                                required="" aria-required="true">
                                            <option value="0"
                                                    <c:if test="${pages.conditions.demandProduct == 0}">selected</c:if>>
                                                问题产品
                                            </option>
                                            <c:forEach items="${productList}" var="product">
                                                <option
                                                        <c:if test="${pages.conditions.demandProduct == product.id}">selected</c:if>
                                                        value="${product.id}">${product.product_name}</option>
                                            </c:forEach>
                                        </select>

                                    </div>
                                    &nbsp;&nbsp;&nbsp;<button type="submit" class="btn btn-primary">搜索</button>
                                    &nbsp;&nbsp;&nbsp;<button type="button" id="resetBut" class="btn btn-reset">重置
                                </button>
                                </form>


                                <div class="ui-jqgrid-bdiv">
                                    <div style="position:relative;">
                                        <div></div>
                                        <table id="cusTable"
                                               class="ui-jqgrid-btable ui-common-table table table-bordered"
                                        >
                                            <tbody>
                                            <tr role="row" style="background: #F5F5F5;">
                                                <!--<td><input th:type="checkbox" name="ches"/>-->

                                                <td>编号
                                                </td>
                                                <td>标题
                                                </td>
                                                <td>描述</td>


                                                <td >驳回人
                                                </td>
                                                <td>驳回时间
                                                </td>
                                                <td>
                                                    驳回理由
                                                </td>
                                                <td>操作
                                                </td>
                                            </tr>


                                            <c:forEach items="${pages.pageDatas}" var="demand">
                                                <tr role="row" id="1" tabindex="-1"
                                                    class="jqgrow ui-row-ltr" demandId="${demand.id}"
                                                    statusText="${demand.status_text}">
                                                    <td>${demand.id}
                                                    </td>
                                                    <td>${demand.title}
                                                    </td>
                                                    <td>
                                                            ${fn:length(demand.detail) > 20 ? fn:substring(demand.detail,0,20) : demand.detail}

                                                    </td>



                                                    <td>
                                                            ${demand.create_name}
                                                    </td>
                                                    <td>
                                                                <fmt:parseDate value="${demand.create_time}"
                                                                               pattern="yyyy-MM-dd"
                                                                               var="receiveDate"></fmt:parseDate>
                                                                <fmt:formatDate value="${receiveDate}"
                                                                                pattern="yyyy-MM-dd"></fmt:formatDate>
                                                    </td>

                                                    <td id="tipsTd" value="${demand.cause}">
                                                            ${fn:length(demand.cause) > 35 ? fn:substring(demand.cause,0,35) : demand.cause}

                                                    </td>

                                                    <td>




                                                            <a id="checkBtn" demId="${demand.id}"
                                                               href="javascript:;"
                                                               class="handleicon" type="button" title="同意驳回"
                                                               isReceive="1"><i
                                                                    class="fa fa-check-circle"></i>
                                                            </a>

                                                            <a id="checkBtn" demId="${demand.id}"

                                                               title="不同意" class="handleicon" type="button"
                                                               isReceive="2"><i class="fa fa-undo"></i>
                                                            </a>





                                                    </td>
                                                </tr>

                                            </c:forEach>


                                            </tbody>
                                        </table>
                                        <c:if test="${pages.totalPages>1 }">
                                            <page:pager pageSize="${pages.pageSize}" currPage="${pages.currPage}"
                                                        totalRecords="${pages.totalRecords}"
                                                        url="${pageContext.request.contextPath}/getRejectSourceList.html?conditions['demandProduct']=${pages.conditions.demandProduct }&conditions['createName']=${pages.conditions.createName }&status=${status }&status1=${status1 }&pageName=${pageName }"/>

                                        </c:if>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>


</body>

<script>

    $(function () {
        $("#resetBut").click(function () {
            $('#createName').val("");
            $('#demandProduct').val("0");
        })
    })

    var param = "";
    $(function () {

        var index = 0;
        var tip_index = 0;
        //tips
        $("[id=tipsTd]").on('mouseenter', function(){
            var htmlStr = "<span style='color:#2f4050'>"+$(this).attr("value")+"</span>";
            tip_index = layer.tips(htmlStr, this, {
            tips: [3,'#fff'],
            time:0
        });
        });

        $("[id=tipsTd]").on('mouseleave', function(){
            layer.close(tip_index);
        });



        //审核按钮
        $("[id=checkBtn]").click(function () {
            var isReceive = $(this).attr('isReceive');

            var title = "驳回申请-同意";
            if (2 == isReceive) {
                title = "驳回申请-不同意";
            }

            //alert($(this).html());
            //alert($(this).attr('status'));
            //alert($(this).attr('demand_id'));
            //alert($(this).parent('tr').attr('custId'));
            index = layer.open({
                type: 2,
                title: title,
                skin: 'ilayui-layer-rm', //加上边框
                area: ['30%', '40%'], //宽高
                content: 'goCheckReject.html?demId='+$(this).attr('demId')+"&isReceive="+isReceive
//                end: function () {
//                    location.reload();
//                }
            });
        });


        //双击tr弹出页面
        $("#cusTable tr td").dblclick(function () {

            //alert($(this).html());
            //alert($(this).attr('custId'));
            //alert($(this).parent('tr').attr('custId'));
            var title = "需求-" + $(this).parent('tr').attr('statusText');
            index = layer.open({
                type: 2,
                title: title,
                skin: 'ilayui-layer-rm', //加上边框
                area: ['90%', '90%'], //宽高
                content: 'demandDetail.html?isCheck=true&demandId=' + $(this).parent('tr').attr('demandId'),
                end: function () {
                    location.reload();
                }
            });
        });
    });

</script>
</html>
